#include "stdafx.h"
#include "CppUnitTest.h"

#include "../ETBarycentric/BCoords.cpp"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace ETBarycentricTests
	{
	TEST_CLASS(UnitTest1)
		{
		public:

			TEST_METHOD(TestMatrixDeterminant)
				{
				// Arrange
				auto row1 = Point{ 1, 2, 3 };
				auto row2 = Point{ -1, 0, 1 };
				auto row3 = Point{ 0, 3, 2 };
				double expected = -8.0;

				// Act
				double actual = Determinant(row1, row2, row3);

				// Assert
				Assert::AreEqual(expected, actual);
				}

			TEST_METHOD(ShouldReturnTrueWhenPointInsideTriangle)
				{
				// Arrange
				Triangle test_triangle = Triangle{ Point{ 1, 0, 0 }, Point{ 0, 1, 0 }, Point{ 0, 0, 1 } };
				Point test_point = Point{ 0.5, 0.25, 0.25 };
				Point test_vertex = Point{ 0, 1, 0 };
				bool expected = true;
				// Act

				bool actual = InsideTriangle(test_triangle, test_point);
				bool actual_vertex = InsideTriangle(test_triangle, test_vertex);
				// Assert

				Assert::AreEqual(expected, actual);
				Assert::AreEqual(expected, actual_vertex);
				}

			TEST_METHOD(ShouldReturnFalseWhenPointOutsideTriangle)
				{
				// Arrange
				Triangle test_triangle = Triangle{ Point{ 1, 0, 0 }, Point{ 0, 1, 0 }, Point{ 0, 0, 1 } };
				Point test_point = Point{ 2, 1, 3 };
				bool expected = false;
				// Act

				bool actual = InsideTriangle(test_triangle, test_point);

				// Assert

				Assert::AreEqual(expected, actual);
				}

		};
	}